<template>
	<view>
		<web-view :webview-styles="webviewStyles" :src="src"></web-view>
	</view>
</template>
<script>
	var wv;
	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: '#ff6a6c'
					}
				},
				webView: '',
				wv: '',
				src: 'https://eos.douyin.com/livesite/live/current',
				title: 'unielepy',
			}
		},
		onReady() {
			let value = uni.getStorageSync('showProduct')
			console.log('value', value);
			if (value) {
				// switch (value){
				// 	case 'liveProduct':
				// 	this.sr
				// 		break;
				// 	default:
				// 		break;
				// }
				this.src = value == 'liveProduct' ? 'https://eos.douyin.com/livesite/live/current' : value == 'login' ?
					'https://buyin.jinritemai.com/mpa/account/login' : 'https://buyin.jinritemai.com/dashboard/live/control'
			}
			uni.removeStorageSync('showProduct')
			// #ifdef APP-PLUS
			var currentWebview = this.$scope.$getAppWebview()
			setTimeout(() => {
				wv = currentWebview.children()[0]
				if (uni.getStorageSync('current')) {
					try {
						let current = uni.getStorageSync('current') - 1
						setTimeout(() => {
							wv.evalJS(`document.getElementsByClassName('hrEBp')[${current}].click()`)
							console.log('back');
							setTimeout(() => {
								uni.navigateBack()
								uni.removeStorageSync('current')
							}, 1000)
						}, 6000)
					} catch (err) {
						console.log('err', err);
					}
				} else if (uni.getStorageSync('current1')) {
					console.log('current');
					try {
						let current = uni.getStorageSync('current1') - 1
						console.log('current', current);
						setTimeout(() => {
							wv.evalJS(`
							document.getElementsByClassName('mobile-modal-footer')[0].click()
							document.getElementById('live-control-goods-list-container').getElementsByClassName('index__goodsAction___1Pz3g')[${current}].getElementsByClassName('lvc2-grey-btn')[2].click()
							`)
							console.log('shopback');
							setTimeout(() => {
								uni.navigateBack()
								uni.removeStorageSync('current1')
							}, 1000)
						}, 7000)
					} catch (err) {
						console.log('err', err);
					}
				}
			}, 1000); //如果是页面初始化调用时，需要延时一下
			// #endif
		}
	}
</script>

<style lang="scss" scoped>
</style>